﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="professoresDisciplina.aspx.cs" Inherits="sistemaSaoJudasTadeu.DynamicData.CustomPages.disciplinas.professoresDisciplina" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Realizar Matrícula</title>
    <link href="Site2.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: 12px;
            font-style: normal;
            color: #000000;
            text-decoration: none;
            width: 83%;
        }
    </style>
</head>
<body>


    <form id="form1" runat="server">
    <asp:Label ID="lblValidacao" runat="server" ForeColor="Red" CssClass="style1"></asp:Label>
    <br />
    <table width="100%" border="0">
      <tr>
        <td><img src="../images/setadireita.gif" width="16" height="14" /></td>
        <td class="style1">Série</td>
        <td>
            <asp:Label ID="lblDescricaoSerie" runat="server" CssClass="style1" Text="Label"></asp:Label>
          </td>
      </tr>
      <tr>
        <td colspan="3"><img src="../images/linhaDivPops.gif" width="400" height="8" /></td>
      </tr>
      <tr>
        <td width="2%"><img src="../images/setadireita.gif" width="16" height="14" /></td>
        <td width="81%" class="style1">Disciplina</td>
        <td width="17%">
            <asp:Label ID="lblDescricaoDisciplina" runat="server" CssClass="style1" 
                Text="Label"></asp:Label>
          </td>
      </tr>
      <tr>
        <td colspan="3"><img src="../images/linhaDivPops.gif" width="400" height="8" /></td>
      </tr>
      <tr>
        <td width="2%"><img src="../images/setadireita.gif" width="16" height="14" /></td>
        <td class="style1">Professores da escola</td>
        <td width="17%">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3"><img src="../images/linhaDivPops.gif" width="400" height="8" /></td>
      </tr>
      
      
      <% 
          
      //loop nos professores da escola

      string sqlProfessores = "select codigoProfessor, nomeProfessor from professor order by nomeProfessor";
          
      System.Data.SqlClient.SqlConnection sqlc = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
      sqlc.Open();



      System.Data.SqlClient.SqlCommand cmdProfessor = new System.Data.SqlClient.SqlCommand(sqlProfessores, sqlc);
      System.Data.SqlClient.SqlDataReader myReaderProfessor = cmdProfessor.ExecuteReader();

      while (myReaderProfessor.Read())
      {

          System.Data.SqlClient.SqlConnection sqlc2 = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
          sqlc2.Open();

          CheckBox cb = new CheckBox();
          cb.ID = myReaderProfessor["codigoProfessor"].ToString();
          cb.Text = myReaderProfessor["nomeProfessor"].ToString();
          
          //verificar se o professor já está cadastrado nesta disciplina
          //em caso positivo checar    

          string sqlProfessorDisciplina = "select * from disciplinaProfessor where codigoProfessor=" + myReaderProfessor["codigoprofessor"].ToString() + " and codigoDisciplina=" + Request["codigoDisciplina"].ToString();

          System.Data.SqlClient.SqlCommand cmdProfessorDisciplina = new System.Data.SqlClient.SqlCommand(sqlProfessorDisciplina, sqlc2);
          System.Data.SqlClient.SqlDataReader myReaderProfessorDisciplina = cmdProfessorDisciplina.ExecuteReader();  
          
      %>
      
      
      <tr>
        <td width="2%"><img src="../images/setadireita.gif" width="16" height="14" /></td>
        <td class="style1"><%Response.Write(myReaderProfessor["nomeProfessor"].ToString()); %></td>
        <td width="17%">
        
        <%if (myReaderProfessorDisciplina.HasRows)
        {
        %>
        
        <input type="checkbox" name="<%Response.Write(myReaderProfessor["codigoProfessor"].ToString()); %>" checked />
        
        <%
        }else{ 
        %>
        <input type="checkbox" name="<%Response.Write(myReaderProfessor["codigoProfessor"].ToString()); %>" />
        <% 
        }
        %>
        
        
        
        </td>
      </tr>
      
      <%
          sqlc2.Close();
      }

      myReaderProfessor.Close();
      cmdProfessor.Dispose();
      sqlc.Close();
      
      myReaderProfessor.Close();
      cmdProfessor.Dispose();
      
          
      %>
            <tr>
        <td colspan="3"><img src="../images/linhaDivPops.gif" width="400" height="8" /></td>
      </tr>
    </table>
    
    <asp:Panel ID="Panel1" runat="server">
        <asp:HiddenField ID="codigoAluno" runat="server" />
    
    
    
    </asp:Panel> 
    
    <p>
    


    <br />
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="Definir" />
    </p>
    <div>
    
    </div>
    
    <input type="hidden" name="codigoDisciplina" value="<%Response.Write(Request["codigoDisciplina"].ToString()); %>" />
    
    <input type="hidden" name="codigoSerie" value="<%Response.Write(Request["codigoSerie"].ToString()); %>" />
    
    </form>
</body>
</html>

